package eiisan.config.aop.request.checker.impl;

import eiisan.config.aop.request.checker.ManualChecker;
import eiisan.service.cache.base.BaseRedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 阻塞型重复请求检查REDIS实现
 */
@Component("repeatRedisChecker")
public class ManualRedisChecker implements ManualChecker {

	/**
	 * redis服务
	 */
	@Autowired
	private BaseRedisCache redisService;

	@Override
	public boolean check(String key) {
		return redisService.exists(key);
	}

	@Override
	public void lock(String key) {
		redisService.set(key, true);
	}

	@Override
	public void free(String key) {
		redisService.delete(key);
	}

}
